package com.axxc.cloud.common.util;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;

public final class StringFormatUtil {

	private StringFormatUtil() {
		throw new IllegalAccessError();
	}

	/**
	 * @param pattern
	 *            "{0}/xxx/xx/{1}"
	 * @param arguments
	 *            aa,bb
	 * @return "{aa}/xxx/xx/{bb}"
	 */
	public static String format(String pattern, Object... arguments) {
		List<String> newArgus = new ArrayList<>(arguments.length);
		for (Object object : arguments) {
			newArgus.add(String.valueOf(object));
		}
		return MessageFormat.format(pattern, newArgus.toArray());
	}

}
